package com.nvelickovic10.snake.beans.food;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.nvelickovic10.snake.main.AppCore;

public class Food {
	protected Point position;

	public Food() {
		position = new Point(-20, -20);
		setPosition(position);
	}

	public Point getPosition() {
		return position;
	}

	public void setPosition(Point position) {
		this.position = position;
	}

	public int getX() {
		return (int) position.getX();
	}

	public int getY() {
		return (int) position.getY();
	}

	public void paintBit(Graphics2D g) {

		BufferedImage img = null;
		try {
			img = ImageIO.read(new File("png/food.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		g.drawImage(img, null, AppCore.getInstance().getFactor() * (getX() - 1)
				+ AppCore.getInstance().getLeft() + 1, AppCore.getInstance()
				.getFactor()
				* (getY() - 1)
				+ AppCore.getInstance().getTop()
				+ 1);
	}
}
